package com.weakteam.androidclient.app;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ToggleButton;
import com.weakteam.androidclient.app.menu.MenuView;
import com.weakteam.androidclient.util.MainProperties;

/**
 * @author Nail
 */
public class MainPage extends Activity {

    private ToggleButton menuButton;
    private ToggleButton cartButton;
    private ToggleButton specialButton;

    private View menuView;
    private ViewGroup contentView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_page);

        this.menuButton = (ToggleButton) findViewById(R.id.menuButton);
        this.cartButton = (ToggleButton) findViewById(R.id.cartButton);
        this.specialButton = (ToggleButton) findViewById(R.id.specialButton);
        this.contentView = (ViewGroup)findViewById(R.id.mainContent);

        this.openMenu();
    }

    public void menuButtonClick(View view) {
        this.menuButton.setChecked(true);
        this.cartButton.setChecked(false);
        this.specialButton.setChecked(false);

        this.openMenu();
    }

    public void cartButtonClick(View view) {
        this.menuButton.setChecked(false);
        this.cartButton.setChecked(true);
        this.specialButton.setChecked(false);

        this.openCart();
    }

    public void specialButtonClick(View view) {
        this.menuButton.setChecked(false);
        this.cartButton.setChecked(false);
        this.specialButton.setChecked(true);

        this.openSpecial();
    }

    private void openMenu() {
        Log.i(MainProperties.LOG_TAG, "openMenu");

        if (this.menuView == null) {
            this.menuView = new MenuView(this.getApplicationContext());
        }
        this.contentView.removeAllViews();
        this.contentView.addView(this.menuView);
    }

    private void openCart() {
        Log.i(MainProperties.LOG_TAG, "openCart");
    }

    private void openSpecial() {
        Log.i(MainProperties.LOG_TAG, "openSpecial");
    }

    @Override
    protected void onResume() {
        super.onResume();
    }
}
